<template>
  <div>
      <hr>
      <h3  ref="node">子组件</h3>
      <span>计时：{{time}} s</span>
  </div>
</template>
<script>
    export default{
        data(){
            return{
                value:10,
                time:0,
                timer:null
            }
        },
        created(){
            this.timer = setInterval(()=>{
                this.time += 1
                console.log("--"+this.time);
            },1000)
        },
        beforeDestroy(){
            console.log('组件即将被销毁.start');
            console.log(this.value);
            console.log(this.$refs.node);
            clearInterval(this.timer);
            console.log('组件即将被销毁.end');
        },
        destroyed(){
            console.log('组件已经被销毁start');
            console.log(this.value);
            console.log(this.$refs.node);
            console.log('组件已经被销毁.end');
        }
    } 
</script>
<style>
     
</style>